﻿namespace Sidvall.UI.Entities
{
    public class SelectableKeyValue<TKey, TValue> : BusinessBase
    {
        #region Public Members

        #region Key

        private TKey _Key;
        public TKey Key
        {
            get
            {
                return _Key;
            }
            set
            {
                _Key = value;
                OnPropertyChanged(nameof(Key), true, true);
            }
        }

        #endregion
        #region Value

        private TValue _Value;
        public TValue Value
        {
            get
            {
                return _Value;
            }
            set
            {
                _Value = value;
                OnPropertyChanged(nameof(Value), true, true);
            }
        }

        #endregion
        #region IsSelected

        private bool _IsSelected;
        public bool IsSelected
        {
            get
            {
                return _IsSelected;
            }
            set
            {
                if (_IsSelected == value)
                    return;
                _IsSelected = value;
                OnPropertyChanged(nameof(IsSelected), true, true);
            }
        }

        #endregion
        #region DataItem

        private object _DataItem = null;
        public object DataItem
        {
            get
            {
                return _DataItem;
            }
            set
            {
                _DataItem = value;
                OnPropertyChanged(nameof(DataItem), true, false);
            }
        }

        #endregion

        #region ToString

        public override string ToString()
        {
            if (this.Key != null)
            {
                if (this.IsSelected)
                    return this.Key.ToString() + ": True";
                else
                    return this.Key.ToString() + ": False";
            }
            return null;
        }

        #endregion

        #endregion
    }
}
